package com_djm_2025_06_09.myString.StringBuilderDemo;

public class StringBuilderDemo7 {
    public static void main(String[] args) {
        int[] arr = {1,2,3};

        String str = myArrToString(arr);
        System.out.println(str);
    }

    public static String myArrToString(int[] arr) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[");

        for(int i = 0;i <arr.length;i++) {
            if(i == arr.length - 1) {
                stringBuilder.append(arr[i]);
            }else{
                stringBuilder.append(arr[i]).append(",");
            }
        }
        stringBuilder.append("]");

        return stringBuilder.toString();

    }



    public static String myArrToString(Object[] arr) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[");

        for(int i = 0;i <arr.length;i++) {
            if(i == arr.length - 1) {
                stringBuilder.append(arr[i]);
            }else{
                stringBuilder.append(arr[i]).append(",");
            }
        }
        stringBuilder.append("]");

        return stringBuilder.toString();

    }

}
